<?php


namespace app\api\controller;

use app\common\controller\Api;
use think\Db;


class Monitoring extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 订单超时监控
     * @throws \think\exception\PDOException
     * @throws \think\Exception
     */
    public function order()
    {

        $result = Db::table('fa_order')
            ->where('status', 0)
            ->where('createtime', '<', time() - 15 * 60)
            ->delete();

        $this->success('ok', [], 200);


    }

    /**
     * 过期的档期监控
     * @throws \think\exception\PDOException
     * @throws \think\Exception
     */
    public function calendar()
    {

        $delTime = strtotime(date("Y-m-d", strtotime("-1 day")));

        $result = Db::table('fa_worker_calendar')
            ->where('endtime', '<', $delTime)
            ->delete();
        $this->success('ok', [], 200);
    }
}